package com.kuaimacode.kframework.json;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.PackageVersion;
import com.fasterxml.jackson.databind.module.SimpleModule;

import java.util.Date;

public final class AppolloJsonUtil {
    private static final ObjectMapper _mapper = new ObjectMapper();

    public static ObjectMapper getMapper() {
        return _mapper;
    }

    static {
        SimpleModule newModule = new SimpleModule("AppolloDateModule", PackageVersion.VERSION);
//        AppolloDateDeserializer dateDeserializer = new AppolloDateDeserializer();
        AppolloDateSerializer dateSerializer = new AppolloDateSerializer();
//        newModule.addDeserializer(Date.class, dateDeserializer);
        newModule.addSerializer(Date.class, dateSerializer);
        _mapper.registerModule(newModule);
    }
}
